/*     */ package com.zimbra.cs.servlet;
/*     */ 
/*     */ import com.zimbra.common.account.Key.AccountBy;
/*     */ import com.zimbra.common.account.Key.DomainBy;
/*     */ import com.zimbra.common.httpclient.HttpClientUtil;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.soap.SoapProtocol;
/*     */ import com.zimbra.common.util.ByteUtil;
/*     */ import com.zimbra.common.util.HttpUtil;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.LogFactory;
/*     */ import com.zimbra.common.util.RemoteIP;
/*     */ import com.zimbra.common.util.RemoteIP.TrustedIPs;
/*     */ import com.zimbra.common.util.ZimbraHttpConnectionManager;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.AuthToken;
/*     */ import com.zimbra.cs.account.AuthTokenException;
/*     */ import com.zimbra.cs.account.Domain;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.httpclient.URLUtil;
/*     */ import com.zimbra.cs.service.AuthProvider;
/*     */ import com.zimbra.cs.servlet.util.AuthUtil;
/*     */ import com.zimbra.cs.util.Zimbra;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Enumeration;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.ServletOutputStream;
/*     */ import javax.servlet.http.HttpServlet;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.httpclient.Header;
/*     */ import org.apache.commons.httpclient.HttpClient;
/*     */ import org.apache.commons.httpclient.HttpMethod;
/*     */ import org.apache.commons.httpclient.HttpState;
/*     */ import org.apache.commons.httpclient.URI;
/*     */ import org.apache.commons.httpclient.methods.GetMethod;
/*     */ import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
/*     */ import org.apache.commons.httpclient.methods.PostMethod;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ZimbraServlet
/*     */   extends HttpServlet
/*     */ {
/*     */   private static final long serialVersionUID = 5025244890767551679L;
/*  77 */   private static Log mLog = LogFactory.getLog(ZimbraServlet.class);
/*     */   private static final String PARAM_ALLOWED_PORTS = "allowed.ports";
/*     */   public static final String QP_ZAUTHTOKEN = "zauthtoken";
/*     */   protected static final String ZIMBRA_FAULT_CODE_HEADER = "X-Zimbra-Fault-Code";
/*     */   protected static final String ZIMBRA_FAULT_MESSAGE_HEADER = "X-Zimbra-Fault-Message";
/*     */   private static final int MAX_PROXY_HOPCOUNT = 3;
/*     */   
/*  84 */   protected String getRealmHeader(String realm) { if (realm == null)
/*  85 */       realm = "Zimbra";
/*  86 */     return "BASIC realm=\"" + realm + "\"";
/*     */   }
/*     */   
/*     */   protected String getRealmHeader(HttpServletRequest req, Domain domain) {
/*  90 */     String realm = null;
/*     */     
/*  92 */     if (domain == null)
/*     */     {
/*  94 */       String host = HttpUtil.getVirtualHost(req);
/*  95 */       if (host != null) {
/*     */         try
/*     */         {
/*  98 */           domain = Provisioning.getInstance().getDomain(Key.DomainBy.virtualHostname, host.toLowerCase(), true);
/*     */         } catch (ServiceException e) {
/* 100 */           mLog.warn("caught exception while getting domain by virtual host: " + host, e);
/*     */         }
/*     */       }
/*     */     }
/*     */     
/* 105 */     if (domain != null) {
/* 106 */       realm = domain.getBasicAuthRealm();
/*     */     }
/* 108 */     return getRealmHeader(realm);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 116 */   private static Map<String, ZimbraServlet> sServlets = new HashMap();
/*     */   private int[] mAllowedPorts;
/*     */   
/*     */   public void init() throws ServletException
/*     */   {
/*     */     try {
/* 122 */       String portsCSV = getInitParameter("allowed.ports");
/* 123 */       if (portsCSV != null)
/*     */       {
/*     */ 
/* 126 */         String[] vals = portsCSV.split("\\s*,\\s*");
/* 127 */         if ((vals == null) || (vals.length == 0)) {
/* 128 */           throw new ServletException("Must specify comma-separated list of port numbers for allowed.ports parameter");
/*     */         }
/* 130 */         List<Integer> allowedPorts = new ArrayList();
/*     */         
/* 132 */         for (int i = 0; i < vals.length; i++) {
/*     */           int port;
/* 134 */           try { port = Integer.parseInt(vals[i]);
/*     */           } catch (NumberFormatException e) {
/* 136 */             throw new ServletException("Invalid port number \"" + vals[i] + "\" in " + "allowed.ports" + " parameter");
/*     */           }
/*     */           
/* 139 */           if (port < 0) {
/* 140 */             throw new ServletException("Invalid port number " + vals[i] + " in " + "allowed.ports" + " parameter; port number must be greater than zero");
/*     */           }
/* 142 */           if (port != 0) {
/* 143 */             allowedPorts.add(Integer.valueOf(port));
/*     */           }
/*     */         }
/* 146 */         this.mAllowedPorts = new int[allowedPorts.size()];
/* 147 */         for (int i = 0; i < allowedPorts.size(); i++) {
/* 148 */           this.mAllowedPorts[i] = ((Integer)allowedPorts.get(i)).intValue();
/*     */         }
/*     */       }
/*     */       
/* 152 */       synchronized (sServlets) {
/* 153 */         String name = getServletName();
/* 154 */         if (sServlets.containsKey(name)) {
/* 155 */           Zimbra.halt("Attempted to instantiate a second instance of " + name);
/*     */         }
/* 157 */         sServlets.put(getServletName(), this);
/* 158 */         mLog.debug("Added " + getServletName() + " to the servlet list");
/*     */       }
/*     */     } catch (Throwable t) {
/* 161 */       Zimbra.halt("Unable to initialize servlet " + getServletName() + "; halting", t);
/*     */     }
/*     */   }
/*     */   
/*     */   /* Error */
/*     */   public static ZimbraServlet getServlet(String name)
/*     */   {
/*     */     // Byte code:
/*     */     //   0: getstatic 44	com/zimbra/cs/servlet/ZimbraServlet:sServlets	Ljava/util/Map;
/*     */     //   3: dup
/*     */     //   4: astore_1
/*     */     //   5: monitorenter
/*     */     //   6: getstatic 44	com/zimbra/cs/servlet/ZimbraServlet:sServlets	Ljava/util/Map;
/*     */     //   9: aload_0
/*     */     //   10: invokeinterface 57 2 0
/*     */     //   15: checkcast 58	com/zimbra/cs/servlet/ZimbraServlet
/*     */     //   18: aload_1
/*     */     //   19: monitorexit
/*     */     //   20: areturn
/*     */     //   21: astore_2
/*     */     //   22: aload_1
/*     */     //   23: monitorexit
/*     */     //   24: aload_2
/*     */     //   25: athrow
/*     */     // Line number table:
/*     */     //   Java source line #166	-> byte code offset #0
/*     */     //   Java source line #167	-> byte code offset #6
/*     */     //   Java source line #168	-> byte code offset #21
/*     */     // Local variable table:
/*     */     //   start	length	slot	name	signature
/*     */     //   0	26	0	name	String
/*     */     //   4	19	1	Ljava/lang/Object;	Object
/*     */     //   21	4	2	localObject1	Object
/*     */     // Exception table:
/*     */     //   from	to	target	type
/*     */     //   6	20	21	finally
/*     */     //   21	24	21	finally
/*     */   }
/*     */   
/*     */   protected boolean isRequestOnAllowedPort(HttpServletRequest request)
/*     */   {
/* 172 */     if ((this.mAllowedPorts != null) && (this.mAllowedPorts.length > 0)) {
/* 173 */       int incoming = request.getLocalPort();
/* 174 */       for (int i = 0; i < this.mAllowedPorts.length; i++) {
/* 175 */         if (this.mAllowedPorts[i] == incoming) {
/* 176 */           return true;
/*     */         }
/*     */       }
/* 179 */       return false;
/*     */     }
/* 181 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   protected void service(HttpServletRequest request, HttpServletResponse response)
/*     */     throws ServletException, IOException
/*     */   {
/* 191 */     boolean allowed = isRequestOnAllowedPort(request);
/* 192 */     if (!allowed) {
/* 193 */       SoapProtocol soapProto = SoapProtocol.Soap12;
/* 194 */       ServiceException e = ServiceException.FAILURE("Request not allowed on port " + request.getLocalPort(), null);
/* 195 */       ZimbraLog.soap.warn(null, e);
/* 196 */       Element fault = SoapProtocol.Soap12.soapFault(e);
/* 197 */       Element envelope = SoapProtocol.Soap12.soapEnvelope(fault);
/* 198 */       byte[] soapBytes = envelope.toUTF8();
/* 199 */       response.setContentType(soapProto.getContentType());
/* 200 */       response.setBufferSize(soapBytes.length + 2048);
/* 201 */       response.setContentLength(soapBytes.length);
/* 202 */       response.setStatus(500);
/* 203 */       response.getOutputStream().write(soapBytes);
/* 204 */       return;
/*     */     }
/* 206 */     super.service(request, response);
/*     */   }
/*     */   
/*     */   public static AuthToken getAuthTokenFromCookie(HttpServletRequest req, HttpServletResponse resp) throws IOException
/*     */   {
/* 211 */     return getAuthTokenFromHttpReq(req, resp, false, false);
/*     */   }
/*     */   
/*     */   public static AuthToken getAuthTokenFromCookie(HttpServletRequest req, HttpServletResponse resp, boolean doNotSendHttpError) throws IOException
/*     */   {
/* 216 */     return getAuthTokenFromHttpReq(req, resp, false, doNotSendHttpError);
/*     */   }
/*     */   
/*     */   public static AuthToken getAdminAuthTokenFromCookie(HttpServletRequest req, HttpServletResponse resp) throws IOException
/*     */   {
/* 221 */     return getAuthTokenFromHttpReq(req, resp, true, false);
/*     */   }
/*     */   
/*     */   public static AuthToken getAdminAuthTokenFromCookie(HttpServletRequest req, HttpServletResponse resp, boolean doNotSendHttpError) throws IOException
/*     */   {
/* 226 */     return getAuthTokenFromHttpReq(req, resp, true, doNotSendHttpError);
/*     */   }
/*     */   
/*     */   public static AuthToken getAdminAuthTokenFromCookie(HttpServletRequest req) {
/* 230 */     return getAuthTokenFromHttpReq(req, true);
/*     */   }
/*     */   
/*     */ 
/*     */   public static AuthToken getAuthTokenFromHttpReq(HttpServletRequest req, HttpServletResponse resp, boolean isAdminReq, boolean doNotSendHttpError)
/*     */     throws IOException
/*     */   {
/* 237 */     AuthToken authToken = null;
/*     */     try {
/* 239 */       authToken = AuthProvider.getAuthToken(req, isAdminReq);
/* 240 */       if (authToken == null) {
/* 241 */         if (!doNotSendHttpError)
/* 242 */           resp.sendError(401, "no authtoken cookie");
/* 243 */         return null;
/*     */       }
/*     */       
/* 246 */       if ((authToken.isExpired()) || (!authToken.isRegistered())) {
/* 247 */         if (!doNotSendHttpError)
/* 248 */           resp.sendError(401, "authtoken expired");
/* 249 */         return null;
/*     */       }
/* 251 */       return authToken;
/*     */     } catch (AuthTokenException e) {
/* 253 */       if (!doNotSendHttpError)
/* 254 */         resp.sendError(401, "unable to parse authtoken"); }
/* 255 */     return null;
/*     */   }
/*     */   
/*     */   public static AuthToken getAuthTokenFromHttpReq(HttpServletRequest req, boolean isAdminReq)
/*     */   {
/* 260 */     AuthToken authToken = null;
/*     */     try {
/* 262 */       authToken = AuthProvider.getAuthToken(req, isAdminReq);
/* 263 */       if (authToken == null) {
/* 264 */         return null;
/*     */       }
/* 266 */       if (authToken.isExpired()) {
/* 267 */         return null;
/*     */       }
/* 269 */       if (!authToken.isRegistered()) {
/* 270 */         return null;
/*     */       }
/* 272 */       return authToken;
/*     */     } catch (AuthTokenException e) {}
/* 274 */     return null;
/*     */   }
/*     */   
/*     */   public static void proxyServletRequest(HttpServletRequest req, HttpServletResponse resp, String accountId)
/*     */     throws IOException, ServiceException
/*     */   {
/* 280 */     Provisioning prov = Provisioning.getInstance();
/* 281 */     Account acct = prov.get(Key.AccountBy.id, accountId);
/* 282 */     if (acct == null) {
/* 283 */       resp.sendError(400, "no such user");
/* 284 */       return;
/*     */     }
/* 286 */     proxyServletRequest(req, resp, prov.getServer(acct), null);
/*     */   }
/*     */   
/*     */   public static void proxyServletRequest(HttpServletRequest req, HttpServletResponse resp, Server server, AuthToken authToken) throws IOException, ServiceException
/*     */   {
/* 291 */     String uri = req.getRequestURI();
/* 292 */     String qs = req.getQueryString();
/* 293 */     if (qs != null) {
/* 294 */       uri = uri + '?' + qs;
/*     */     }
/* 296 */     proxyServletRequest(req, resp, server, uri, authToken);
/*     */   }
/*     */   
/*     */   public static void proxyServletRequest(HttpServletRequest req, HttpServletResponse resp, Server server, String uri, AuthToken authToken) throws IOException, ServiceException
/*     */   {
/* 301 */     if (server == null) {
/* 302 */       resp.sendError(400, "cannot find remote server");
/* 303 */       return;
/*     */     }
/*     */     
/* 306 */     String url = getProxyUrl(req, server, uri);
/* 307 */     mLog.debug("Proxy URL = %s", new Object[] { url });
/* 308 */     HttpMethod method; if (req.getMethod().equalsIgnoreCase("GET")) {
/* 309 */       method = new GetMethod(url.toString()); } else { HttpMethod method;
/* 310 */       if ((req.getMethod().equalsIgnoreCase("POST")) || (req.getMethod().equalsIgnoreCase("PUT"))) {
/* 311 */         PostMethod post = new PostMethod(url.toString());
/* 312 */         post.setRequestEntity(new InputStreamRequestEntity(req.getInputStream()));
/* 313 */         method = post;
/*     */       } else {
/* 315 */         resp.sendError(500, "cannot proxy method: " + req.getMethod()); return;
/*     */       } }
/*     */     HttpMethod method;
/* 318 */     HttpState state = new HttpState();
/* 319 */     String hostname = method.getURI().getHost();
/* 320 */     if (authToken != null) {
/* 321 */       authToken.encode(state, false, hostname);
/*     */     }
/*     */     try {
/* 324 */       proxyServletRequest(req, resp, method, state);
/*     */     } finally {
/* 326 */       method.releaseConnection();
/*     */     }
/*     */   }
/*     */   
/*     */   private static boolean hasZimbraAuthCookie(HttpState state) {
/* 331 */     org.apache.commons.httpclient.Cookie[] cookies = state.getCookies();
/* 332 */     if (cookies == null) {
/* 333 */       return false;
/*     */     }
/* 335 */     for (org.apache.commons.httpclient.Cookie c : cookies) {
/* 336 */       if (c.getName().equals("ZM_AUTH_TOKEN"))
/* 337 */         return true;
/*     */     }
/* 339 */     return false;
/*     */   }
/*     */   
/*     */   public static void proxyServletRequest(HttpServletRequest req, HttpServletResponse resp, HttpMethod method, HttpState state)
/*     */     throws IOException, ServiceException
/*     */   {
/* 345 */     javax.servlet.http.Cookie[] cookies = req.getCookies();
/* 346 */     String hostname = method.getURI().getHost();
/* 347 */     boolean hasZMAuth = hasZimbraAuthCookie(state);
/* 348 */     if (cookies != null) {
/* 349 */       for (int i = 0; i < cookies.length; i++) {
/* 350 */         if ((!cookies[i].getName().equals("ZM_AUTH_TOKEN")) || (!hasZMAuth))
/*     */         {
/* 352 */           state.addCookie(new org.apache.commons.httpclient.Cookie(hostname, cookies[i].getName(), cookies[i].getValue(), "/", null, false)); }
/*     */       }
/*     */     }
/* 355 */     HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
/* 356 */     if (state != null) {
/* 357 */       client.setState(state);
/*     */     }
/* 359 */     int hopcount = 0;
/* 360 */     for (Enumeration<?> enm = req.getHeaderNames(); enm.hasMoreElements();) {
/* 361 */       String hname = (String)enm.nextElement();String hlc = hname.toLowerCase();
/* 362 */       if (hlc.equals("x-zimbra-hopcount"))
/* 363 */         try { hopcount = Math.max(Integer.parseInt(req.getHeader(hname)), 0);
/* 364 */         } catch (NumberFormatException e) {} else if ((hlc.startsWith("x-")) || (hlc.startsWith("content-")) || (hlc.equals("authorization")))
/* 365 */         method.addRequestHeader(hname, req.getHeader(hname));
/*     */     }
/* 367 */     if (hopcount >= 3)
/* 368 */       throw ServiceException.TOO_MANY_HOPS(HttpUtil.getFullRequestURL(req));
/* 369 */     method.addRequestHeader("X-Zimbra-Hopcount", Integer.toString(hopcount + 1));
/* 370 */     if (method.getRequestHeader("X-Zimbra-Orig-Url") == null)
/* 371 */       method.addRequestHeader("X-Zimbra-Orig-Url", req.getRequestURL().toString());
/* 372 */     String ua = req.getHeader("User-Agent");
/* 373 */     if (ua != null) {
/* 374 */       method.setRequestHeader("User-Agent", ua);
/*     */     }
/*     */     
/* 377 */     int statusCode = -1;
/* 378 */     for (int retryCount = 3; (statusCode == -1) && (retryCount > 0); retryCount--) {
/* 379 */       statusCode = HttpClientUtil.executeMethod(client, method);
/*     */     }
/* 381 */     if (statusCode == -1) {
/* 382 */       resp.sendError(503, "retry limit reached");
/* 383 */       return; }
/* 384 */     if (statusCode >= 300) {
/* 385 */       resp.sendError(statusCode, method.getStatusText());
/* 386 */       return;
/*     */     }
/*     */     
/* 389 */     Header[] headers = method.getResponseHeaders();
/* 390 */     for (int i = 0; i < headers.length; i++) {
/* 391 */       String hname = headers[i].getName();String hlc = hname.toLowerCase();
/* 392 */       if ((hlc.startsWith("x-")) || (hlc.startsWith("content-")) || (hlc.startsWith("www-")))
/* 393 */         resp.addHeader(hname, headers[i].getValue());
/*     */     }
/* 395 */     InputStream responseStream = method.getResponseBodyAsStream();
/* 396 */     if ((responseStream == null) || (resp.getOutputStream() == null))
/* 397 */       return;
/* 398 */     ByteUtil.copy(method.getResponseBodyAsStream(), false, resp.getOutputStream(), false);
/*     */   }
/*     */   
/*     */   protected boolean isAdminRequest(HttpServletRequest req) throws ServiceException {
/* 402 */     int adminPort = Provisioning.getInstance().getLocalServer().getIntAttr("zimbraAdminPort", -1);
/* 403 */     if (req.getLocalPort() == adminPort)
/*     */     {
/* 405 */       int mailPort = Provisioning.getInstance().getLocalServer().getIntAttr("zimbraMailPort", -1);
/* 406 */       if (mailPort == adminPort) {
/* 407 */         return getAdminAuthTokenFromCookie(req) != null;
/*     */       }
/* 409 */       return true;
/*     */     }
/* 411 */     return false;
/*     */   }
/*     */   
/*     */   public AuthToken cookieAuthRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServiceException
/*     */   {
/* 416 */     AuthToken at = isAdminRequest(req) ? getAdminAuthTokenFromCookie(req, resp, true) : getAuthTokenFromCookie(req, resp, true);
/* 417 */     return at;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   @Deprecated
/*     */   public Account basicAuthRequest(HttpServletRequest req, HttpServletResponse resp, boolean sendChallenge)
/*     */     throws IOException, ServiceException
/*     */   {
/* 428 */     return AuthUtil.basicAuthRequest(req, resp, this, sendChallenge);
/*     */   }
/*     */   
/*     */   public static String getAccountPath(Account acct) {
/* 432 */     return "/" + acct.getName();
/*     */   }
/*     */   
/*     */   public static String getServiceUrl(Account acct, String path) throws ServiceException {
/* 436 */     Provisioning prov = Provisioning.getInstance();
/* 437 */     Server server = prov.getServer(acct);
/*     */     
/* 439 */     if (server == null) {
/* 440 */       throw ServiceException.FAILURE("unable to retrieve server for account" + acct.getName(), null);
/*     */     }
/*     */     
/* 443 */     return getServiceUrl(server, prov.getDomain(acct), path + getAccountPath(acct));
/*     */   }
/*     */   
/*     */   public static String getServiceUrl(Server server, Domain domain, String path) throws ServiceException
/*     */   {
/* 448 */     return URLUtil.getPublicURLForDomain(server, domain, path, true);
/*     */   }
/*     */   
/*     */   protected static String getProxyUrl(HttpServletRequest req, Server server, String path) throws ServiceException {
/* 452 */     int servicePort = req == null ? -1 : req.getLocalPort();
/* 453 */     Provisioning prov = Provisioning.getInstance();
/* 454 */     Server localServer = prov.getLocalServer();
/* 455 */     if ((!prov.isOfflineProxyServer(server)) && (servicePort == localServer.getIntAttr("zimbraAdminPort", 0))) {
/* 456 */       return URLUtil.getAdminURL(server, path);
/*     */     }
/* 458 */     return URLUtil.getServiceURL(server, path, servicePort == localServer.getIntAttr("zimbraMailSSLPort", 0));
/*     */   }
/*     */   
/*     */   protected void returnError(HttpServletResponse resp, ServiceException e) {
/* 462 */     resp.setHeader("X-Zimbra-Fault-Code", e.getCode());
/* 463 */     resp.setHeader("X-Zimbra-Fault-Message", e.getMessage());
/* 464 */     resp.setStatus(500);
/*     */   }
/*     */   
/*     */   public static String getOrigIp(HttpServletRequest req) {
/* 468 */     RemoteIP remoteIp = new RemoteIP(req, getTrustedIPs());
/* 469 */     return remoteIp.getOrigIP();
/*     */   }
/*     */   
/*     */   public static String getClientIp(HttpServletRequest req) {
/* 473 */     RemoteIP remoteIp = new RemoteIP(req, getTrustedIPs());
/* 474 */     return remoteIp.getClientIP();
/*     */   }
/*     */   
/*     */   public static void addRemoteIpToLoggingContext(HttpServletRequest req) {
/* 478 */     RemoteIP remoteIp = new RemoteIP(req, getTrustedIPs());
/* 479 */     remoteIp.addToLoggingContext();
/*     */   }
/*     */   
/*     */   public static RemoteIP.TrustedIPs getTrustedIPs() {
/*     */     try {
/* 484 */       Server server = Provisioning.getInstance().getLocalServer();
/* 485 */       return new RemoteIP.TrustedIPs(server.getMultiAttr("zimbraMailTrustedIP"));
/*     */     } catch (ServiceException e) {
/* 487 */       ZimbraLog.misc.warn("failed to get trusted IPs, only localhost will be trusted", e);
/*     */     }
/* 489 */     return new RemoteIP.TrustedIPs(null);
/*     */   }
/*     */   
/*     */   public static void addUAToLoggingContext(HttpServletRequest req) {
/* 493 */     ZimbraLog.addUserAgentToContext(req.getHeader("User-Agent"));
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/servlet/ZimbraServlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */